package com.qin.entity;

import com.qin.enums.Version_type;
import com.qin.service.ExecuteService;
import com.qin.service.impl.ExecuteServiceImpl;
import lombok.Data;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Data
public class ExecuteBean{

    //函数输入参数
    private String input_paravalue;

    //版本名称
    private String version_name;
    //版本日期
    private String version_date;
    //版本类型
    private Version_type version_type;
    //版本说明
    private String version_descption;

    //系统名称
    private String system_name;
    //环境
    private String environment_stg;
    //系统url
    private String system_url;

    //数据库SID
    private String database_sid;
    //数据库连接串
    private String database_string;
    //数据库用户名
    private String database_username;
    //数据库密码
    private String database_password;

    //全局变量Map<变量名, 变量值>
    private Map<String, String> paraMap = new HashMap<String, String>();
    //数据库查询结果Map<组件ID, 查询结果List>
    private Map<String, List<Map>> dbQueryResultMap = new HashMap<String, List<Map>>();
    //接口调用结果Map<组件ID, 接口调用结果>
    private Map<String, String> interfaceResultMap = new HashMap<String, String>();

    //执行id
    private String execute_id;
    //函数id
    private String function_id;
    //案例id
    private String testcase_id;
    //组件id
    private String component_id;
    //子组件id
    private String subcomponent_id;
//
//    //日志内容
//    private String log_content;

    public void complete(){
        //补全本ExecuteBean对象的各属性
        ExecuteService executeService = new ExecuteServiceImpl();
        ExecuteBean executeBean = executeService.queryExecuteBean(this);

        if(executeBean != null){
            this.setVersion_name(executeBean.version_name);
            this.setVersion_date(executeBean.version_date);
            this.setVersion_type(executeBean.version_type);
            this.setVersion_descption(executeBean.version_descption);
            this.setSystem_name(executeBean.system_name);
            this.setEnvironment_stg(executeBean.environment_stg);
            this.setSystem_url(executeBean.system_url);
            this.setDatabase_sid(executeBean.database_sid);
            this.setDatabase_string(executeBean.database_string);
            this.setDatabase_username(executeBean.database_username);
            this.setDatabase_password(executeBean.database_password);
        }else {
            System.out.println(version_date+","+system_name);
            throw new NullPointerException();
        }
    }
}
